package com.keti.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.keti.Dao.ApplyPurchaseDao;
import com.keti.Dao.ApplyReceiveDao;
import com.keti.DaoImpl.ApplyPurchaseDaoImpl;
import com.keti.DaoImpl.ApplyReceiveDaoImpl;
import com.keti.pojo.ApplyPurchase;
import com.keti.pojo.ApplyReceive;

/**
 * Servlet implementation class AddApplyPurchaseServlet
 */
@WebServlet("/AddApplyPurchaseServlet")
public class AddApplyPurchaseServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 request.setCharacterEncoding("utf-8");
		 response.setContentType("text/html;charset=utf-8");
		 int uid = Integer.parseInt(request.getParameter("uid"));
		  String uname = request.getParameter("uname");
		  String sname = request.getParameter("sname");
		  String reason = request.getParameter("reason");
		  ApplyPurchase ap = new ApplyPurchase();
		  ap.setUid(uid);
		  ap.setUname(uname);
		  ap.setSname(sname);
		  ap.setStatus("未审核");
		  ap.setReason(reason);
		  ApplyPurchaseDao apd =new ApplyPurchaseDaoImpl();
		  apd.add(ap);
		  response.sendRedirect("UserInterfaceServlet");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
